import {
  Entity,
  Column,
  ManyToOne,
  JoinColumn,
  OneToMany,
  ManyToMany,
  JoinTable,
} from "typeorm";
import BaseEntity from "./base";
import { Post } from "./post";
import { User } from "./user";
import { Tag } from "./tag";

@Entity("boards")
export class Board extends BaseEntity {
  @Column()
  title: string;

  @Column({ nullable: true })
  description: string;

  @OneToMany(() => Post, (post) => post.attachments)
  posts: Post[];

  @ManyToOne(() => User, (user) => user.boards)
  @JoinColumn()
  user: User;

  @ManyToMany(() => Tag, (tag) => tag.boards)
  @JoinTable()
  tags: Tag[];
}
